#include <driver.h>
#include <klibc/string.h>
#include <config.h>
#include <device.h>
#include <arch.h>
#include "drivers/bus/pci/pci.h"
#include "drivers/net/rs232/rs232.h"
#include "drivers/video/vesa/vesa.h"

/* init driver */
int 
drv_init()
{
	#ifndef DRV
		return 0;
	#endif
	
	drvlist = NULL;
	
	/* provvisorio */
	#ifdef PCI
	drv_pci.next = drvlist;
	drvlist = &drv_pci;
	#endif
	#ifdef RS232
	drv_rs232.next = drvlist;
	drvlist = &drv_rs232;
	#endif
	#ifdef VESA
	drv_vesa.next = drvlist;
	drvlist = &drv_vesa;
	#endif
	return 0;
}



/* get the i driver */
drv_t *
drv_iget(int i)
{
	#ifdef NO_DRV
		return (drv_t *) NULL;
	#endif
	
	drv_t *d = drvlist;
	int j = 0;
	
	while(d != NULL)
	{
		if(i == j)
			return d;
			
		j++;
		d = d->next;
	}
	return NULL;	
}
